#include <cstdio>
using namespace std;

struct list_node {
	int x, y;
	list_node *next;
};

typedef list_node Lnode;
typedef list_node * link;

link a, b, end, ans;

int main() {
	a = new Lnode;
	b = new Lnode;
	ans = new Lnode;
	int n, x, y;
	end = a;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d %d", &x, &y);
		link now = new Lnode;
		now->x = x;
		now->y = y;
		now->next = NULL;
		end->next = now;
		end = now; 
	}

	end = b;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d %d", &x, &y);
		link now = new Lnode;
		now->x = x;
		now->y = y;
		now->next = NULL;
		end->next = now;
		end = now; 
	}
	link pa = a->next, pb = b->next, p = ans;
	while (1) {
		if (pa == NULL) {
			p->next = pb;
			break;
		}
		if (pb == NULL) {
			p->next = pa;
			break;
		}
		if (pa->y == pb->y) {
			link now = new Lnode;
			now->x = pa->x + pb->x;
			now->y = pa->y;
			p->next = now;
			p = now;
			pa = pa->next;
			pb = pb->next; 
		} else if (pa->y > pb->y) {
			link now = new Lnode;
			now->x = pa->x;
			now->y = pa->y;
			p->next = now;
			p = now;
			pa = pa->next;
		} else if (pa->y < pb->y) {
			link now = new Lnode;
			now->x = pb->x;
			now->y = pb->y;
			p->next = now;
			p = now;
			pb = pb->next;
		}
	}
	n = 0;
	p = ans->next;
	while (1) {
		if (p == NULL)break;
		++n;
		p = p->next;
	}
	printf("%d\n", n);
	p = ans->next;
	while (1) {
		if (p == NULL)break;
		printf("%d %d\n", p->x, p->y);
		p = p->next;
	}
	return 0;
}
